package com.wjk.kylin.mall.common.web.transactional;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Slf4j
@Service
public class TransactionalHandle {

//    @Transactional
//    public <T> void execute(Supplier<T> supplier) {
//        supplier.get();
//    }

    @Transactional(rollbackFor = Exception.class)
    public boolean execute(TransactionalFunction function) {
        log.info("======> start transactional execute method");
        boolean flag = function.run();
        log.info("======> end transactional execute method,flag:{}",flag);
        return flag;
    }
}
